class PipTools < Formula
  include Language::Python::Virtualenv

  desc "Locking and sync for Pip requirements files"
  homepage "https://pip-tools.readthedocs.io"
  url "https://files.pythonhosted.org/packages/b1/5a/29da7316a6b36a5045454ced356849fd17538a3d53adc9af1c2474de1032/pip-tools-6.12.2.tar.gz"
  sha256 "8b903696df4598b10d469026ef9995c5f9a874b416e88e7a214884ebe4a70245"
  license "BSD-3-Clause"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_ventura:  "e06400607ffa4a6d4cb1c874afbdfc57cc919d642da358bd6010195f0798605a"
    sha256 cellar: :any_skip_relocation, arm64_monterey: "51bf500dab8edf51c8016b169a47ed11471722d69b86414592e9ea7cfcdc0c85"
    sha256 cellar: :any_skip_relocation, arm64_big_sur:  "d56c9d89ac46b8da44ed80d74177b1b6c0b192cafcbd805a2cdbc7ac85454048"
    sha256 cellar: :any_skip_relocation, ventura:        "aa56d429bccac669c13bc8a4e9917d6e9bb0aead17f76f7785c5e76855e53165"
    sha256 cellar: :any_skip_relocation, monterey:       "8afb4736cae66ea7b2bab72e95b0360b00f87ca15b8854d4f76d295dd268d07c"
    sha256 cellar: :any_skip_relocation, big_sur:        "a53ce2b1b3d1863035521aba75ebe170ef52f313c250d4bcf923fbebcc965e4c"
    sha256 cellar: :any_skip_relocation, x86_64_linux:   "6ec48b8bb532c809caecfb8200279f71c8ae2d74829a30ebbd897da047f05a58"
  end

  depends_on "python@3.11"

  resource "build" do
    url "https://files.pythonhosted.org/packages/de/1c/fb62f81952f0e74c3fbf411261d1adbdd2d615c89a24b42d0fe44eb4bcf3/build-0.10.0.tar.gz"
    sha256 "d5b71264afdb5951d6704482aac78de887c80691c52b88a9ad195983ca2c9269"
  end

  resource "click" do
    url "https://files.pythonhosted.org/packages/59/87/84326af34517fca8c58418d148f2403df25303e02736832403587318e9e8/click-8.1.3.tar.gz"
    sha256 "7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e"
  end

  resource "packaging" do
    url "https://files.pythonhosted.org/packages/47/d5/aca8ff6f49aa5565df1c826e7bf5e85a6df852ee063600c1efa5b932968c/packaging-23.0.tar.gz"
    sha256 "b6ad297f8907de0fa2fe1ccbd26fdaf387f5f47c7275fedf8cce89f99446cf97"
  end

  resource "pyproject_hooks" do
    url "https://files.pythonhosted.org/packages/25/c1/374304b8407d3818f7025457b7366c8e07768377ce12edfe2aa58aa0f64c/pyproject_hooks-1.0.0.tar.gz"
    sha256 "f271b298b97f5955d53fb12b72c1fb1948c22c1a6b70b315c54cedaca0264ef5"
  end

  resource "wheel" do
    url "https://files.pythonhosted.org/packages/a2/b8/6a06ff0f13a00fc3c3e7d222a995526cbca26c1ad107691b6b1badbbabf1/wheel-0.38.4.tar.gz"
    sha256 "965f5259b566725405b05e7cf774052044b1ed30119b5d586b2703aafe8719ac"
  end

  def install
    virtualenv_install_with_resources
  end

  test do
    (testpath/"requirements.in").write <<~EOS
      pip-tools
      typing-extensions
    EOS

    compiled = shell_output("#{bin}/pip-compile requirements.in -q -o -")
    assert_match "This file is autogenerated by pip-compile", compiled
    assert_match "# via pip-tools", compiled
  end
end
